#ifndef FINDREPLACEDIALOG_H
#define FINDREPLACEDIALOG_H

//搜索对话框类
class FindReplaceDialog : public QDialog
{
    Q_OBJECT
public:
    FindReplaceDialog(QWidget *parent = 0, QTabWidget *tabWidget = nullptr); //构造函数

    QTabWidget *searchDialogTabWidget=nullptr;

    QLineEdit *openedFilesSearchLineEdit = nullptr;
    QCheckBox *openedFilesReplaceCheckBox = nullptr;
    QLineEdit *openedFilesReplaceLineEdit = nullptr;
    QCheckBox *openedFilesCaseCheckBox = nullptr;
    QCheckBox *openedFilesWholeWordsCheckBox = nullptr;
    QPushButton *openedFilesFindReplaceButton = nullptr;

    QLineEdit *projectSearchLineEdit = nullptr;
    QCheckBox *projectReplaceCheckBox = nullptr;
    QLineEdit *projectReplaceLineEdit = nullptr;
    QCheckBox *projectCaseCheckBox = nullptr;
    QCheckBox *projectWholeWordsCheckBox = nullptr;
    QPushButton *projectFindReplaceButton = nullptr;

    QComboBox *findComboBox = nullptr;
    QRadioButton *upwardRadioButton = nullptr;
    QCheckBox *caseCheckBox = nullptr;
    QCheckBox *wholeWordsCheckBox = nullptr;

    void setReplaceOn(bool replaceOn)
    {
        this->replaceOn = replaceOn;
    }

private:
    QPushButton *openedFilesCancelButton = nullptr;
    QPushButton *projectCancelButton = nullptr;

    QLabel *findLabel = nullptr;

    QCheckBox *replaceCheckBox = nullptr;
    QComboBox *replaceComboBox = nullptr;

    QGroupBox *optionsGroupBox = nullptr;

    QGroupBox *directionsGroupBox = nullptr;
    QRadioButton *downwardRadioButton = nullptr;

    QPushButton *findReplaceButton =nullptr; //定义find按钮
    QPushButton *replaceAllButton = nullptr; //定义replaceAll按钮
    QPushButton *cancelButton = nullptr; //定义cancel按钮

    QTabWidget *tabWidget = nullptr;

    bool replaceOn = false;

    void replaceCheckBoxStateChanged(Qt::CheckState state);
    void openedFilesReplaceCheckBoxStateChanged(Qt::CheckState state);
    void projectReplaceCheckBoxStateChanged(Qt::CheckState state);
    void findReplaceButtonClicked(); //findReplace按钮点击时的处理函数
    void replaceAllButtonClicked();
    void findLineEditReturnPressed();
    void replaceLineEditReturnPressed();
    void cancelButtonClicked();//Cancel按钮点击时的处理函数
    void showEvent(QShowEvent *event);
    void currentTabChanged(int currentIndex);
};
#endif
